package y23.Sep;
//https://www.nowcoder.com/share/jump/5867789821693204467449
//牛客 求平方根
public class Test2 {
    public static void main(String[] args) {
        System.out.println(sqrt(2));
        System.out.println(sqrt(2143195649));
    }
    public static int sqrt (int x) {
        if(x < 2){
            return x;
        }else if(x <= 4){
            return x / 2;
        }
        int mid  = 2;
        while(mid * mid <= x){
            mid++;
        }
        return mid-1;
    }
}
